home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / basic / mildred / mildred.lha / lha / SineExample.lha / SineExample1.ascii < prev    next >
Text File  |  1999-03-20  |  4KB  |  109 lines

  1. ;Wavey Logo Mildred Library Example.
  2. ;
  3. ;Programmed by : Mikkel Loekke, aka. FlameDuck.
  4. ;
  5. ;Please read the README file.
  6. ;
  7. ;Modified by Paul West to use OffsetList with MScroll and lookup tables
  8.  
  9. WBStartup
  10. NoCli
  11.  
  12. DEFTYPE.l
  13.  
  14. degrad.q = Pi/180                   ; Since the computer works in
  15.                                     ; radians, we need this value
  16.                                     ; to convert our angle to radians.
  17.                                     ; (Or something) :o)
  18.  
  19. Dim Lookup.w(570)                   ; Setup our sine lookup table.
  20. For i=0 To 570                      ; Array needs to be .w. If you use .q it will not work properly
  21.   Lookup(i)=Sin((i)*degrad*3)*30
  22. Next
  23.  
  24. NEWTYPE.OffsetList
  25.   LineWidth.w
  26.   X1Offset.w
  27.   X2Offset.w
  28.   SourceModuloOffset.w
  29. End NEWTYPE
  30. Dim rows.OffsetList(570)
  31. rows(0)\LineWidth=320,0,Lookup(0),0
  32. For y=1 To 570                            ; Do the sine wavey bits.
  33.   rows(y)\LineWidth=320
  34.   rows(y)\X1Offset=Lookup(y)-Lookup(y-1)
  35.   rows(y)\X2Offset=0
  36.   rows(y)\SourceModuloOffset=0
  37. Next
  38.  
  39. MCPU Processor                      ; Tell Mildred which CPU it should use.
  40. Mc2pCPUmode Processor               ; Tell Mildred which CPU it should us for c2p.
  41.  
  42. MReserveBitmaps 2                   ; Tell Mildred that we're going to use 2 chunky bitmaps.
  43. MReservec2pWindows 1                ; Tell it we only need one c2p display.
  44.  
  45. .initgraphics
  46. MCludgeBitmap 0,320,210,?inclogo    ; Go fetch our original chunky image.
  47. MBitmap 1,320,210                   ; This will contain our chunky buffer.
  48.  
  49. Mc2pWindow 0,320,210                ; Setup structures for c2p conversions.
  50.  
  51. InitBank 0,320*210,$10002           ; Get some free CHIP memory.
  52. CludgeBitMap 0,320,210,8,Bank(0)    ; And make it a planar bitmap.
  53.  
  54. Dim scrtaglst.TagItem(7)            ; All this stuff sets up our
  55. scrtaglst(0)\ti_Tag = #SA_Left      ; Taglist for the screen we
  56. scrtaglst(0)\ti_Data = 0          ; want. As you can see, it's
  57. scrtaglst(1)\ti_Tag = #SA_Depth     ; rather non-standard.
  58. scrtaglst(1)\ti_Data = 8            ; it doesn't have to be, it's
  59. scrtaglst(2)\ti_Tag = #SA_Width     ; just that this routine needs
  60. scrtaglst(2)\ti_Data = 320          ; a larger screen to avoid
  61. scrtaglst(3)\ti_Tag = #SA_Height    ; clipping.
  62. scrtaglst(3)\ti_Data = 210
  63. scrtaglst(4)\ti_Tag = #SA_BitMap
  64. scrtaglst(4)\ti_Data = Addr BitMap (0)
  65. scrtaglst(5)\ti_Tag = #SA_ShowTitle
  66. scrtaglst(5)\ti_Data = 0
  67. scrtaglst(6)\ti_Tag = #SA_Draggable
  68. scrtaglst(6)\ti_Data = 0
  69. scrtaglst(7)\ti_Tag = #TAG_END      ; The most important tag of them all.
  70.  
  71.  
  72. ScreenTags 0,"MildredDEMO",&scrtaglst(0) ; Open our intuition screen.
  73.  
  74. DecodePalette 0,?incpal             ; Get our IncBin'ed palette info.
  75.  
  76. ShowPalette 0                       ; Attach our palette to the screen.
  77.  
  78. MUseBitmap 1                        ; Tell Mildred to use our main
  79.                                     ; chunky buffer (just in case)
  80.  
  81. Repeat                              ; Repeat our mainloop ....
  82.   Mc2p Bank(0)                      ; Convert our chunky buffer to
  83.                                     ; our planar bitmap.
  84.  
  85.   MCls                              ; Clear our chunky buffer
  86.  
  87.   Temp.w=rows(deg MOD 360)\X1Offset
  88.   rows(deg MOD 360)\X1Offset=Lookup(deg MOD 360)
  89.   MScroll 0,0,320,210,0,0,0,&rows(deg MOD 360) ; Tell Mildred how to move our graphics arround, and where to put them.
  90.   rows(deg MOD 360)\X1Offset=Temp
  91.  
  92.   deg+1                             ; do another degree on the sinewave.
  93.  
  94. Until RawStatus($45)                ; .... Until we press Escape.
  95.  
  96. End                                 ; End our nice program.
  97.  
  98.  
  99. Even4                               ; put following data on an even address. Minor speed increase.
  100. .incpal
  101. IncBin "IntroLogo.PAL" ; Include our palette information in the binary.
  102.  
  103. Even4                               ; Same as last time :o)
  104. Ds.l 16
  105. .inclogo
  106. IncBin "IntroLogo.CNK" ; Include our chunky logo.
  107. Ds.l 16
  108.  
  109.